<template>
  <div class="flex flex-col min-h-screen">
    <header class="sticky top-0 z-50 bg-white shadow-md">
      <div class="container py-4">
        <div class="flex items-center justify-between">
          <router-link to="/" class="flex items-center space-x-2" @click="appStore.closeMenu">
            <img src="@/assets/images/logo.png" alt="Logo" class="h-10" />
            <span class="text-xl font-bold text-secondary-dark">{{ appStore.companyName }}</span>
          </router-link>
          
          <!-- 桌面导航 -->
          <nav class="hidden md:flex items-center space-x-8">
            <router-link to="/" class="font-medium">首页</router-link>
            <router-link to="/about" class="font-medium">关于我们</router-link>
            <router-link to="/products" class="font-medium">产品与服务</router-link>
            <router-link to="/news" class="font-medium">新闻动态</router-link>
            <router-link to="/contact" class="font-medium">联系我们</router-link>
          </nav>
          
          <!-- 移动端菜单按钮 -->
          <button class="md:hidden" @click="appStore.toggleMenu">
            <svg v-if="!appStore.isMenuOpen" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
            </svg>
            <svg v-else xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
              <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
            </svg>
          </button>
        </div>
      </div>
      
      <!-- 移动端导航菜单 -->
      <div v-if="appStore.isMenuOpen" class="md:hidden bg-white shadow-lg">
        <div class="container py-4">
          <nav class="flex flex-col space-y-4">
            <router-link to="/" class="font-medium" @click="appStore.closeMenu">首页</router-link>
            <router-link to="/about" class="font-medium" @click="appStore.closeMenu">关于我们</router-link>
            <router-link to="/products" class="font-medium" @click="appStore.closeMenu">产品与服务</router-link>
            <router-link to="/news" class="font-medium" @click="appStore.closeMenu">新闻动态</router-link>
            <router-link to="/contact" class="font-medium" @click="appStore.closeMenu">联系我们</router-link>
          </nav>
        </div>
      </div>
    </header>
    
    <main class="flex-grow">
      <slot></slot>
    </main>
    
    <footer class="bg-secondary text-white">
      <div class="container py-12">
        <div class="grid grid-cols-1 md:grid-cols-4 gap-8">
          <div>
            <h5 class="text-white mb-4">{{ appStore.companyName }}</h5>
            <p class="text-gray-300 mb-4">{{ appStore.companySlogan }}</p>
            <div class="flex space-x-4">
              <a href="#" class="text-gray-300 hover:text-white">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
                  <path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"/>
                </svg>
              </a>
              <a href="#" class="text-gray-300 hover:text-white">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
                  <path d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z"/>
                </svg>
              </a>
              <a href="#" class="text-gray-300 hover:text-white">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="currentColor" viewBox="0 0 24 24">
                  <path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z"/>
                </svg>
              </a>
            </div>
          </div>
          
          <div>
            <h5 class="text-white mb-4">快速链接</h5>
            <nav class="flex flex-col space-y-2">
              <router-link to="/" class="text-gray-300 hover:text-white">首页</router-link>
              <router-link to="/about" class="text-gray-300 hover:text-white">关于我们</router-link>
              <router-link to="/products" class="text-gray-300 hover:text-white">产品与服务</router-link>
              <router-link to="/news" class="text-gray-300 hover:text-white">新闻动态</router-link>
              <router-link to="/contact" class="text-gray-300 hover:text-white">联系我们</router-link>
            </nav>
          </div>
          
          <div>
            <h5 class="text-white mb-4">联系我们</h5>
            <div class="flex flex-col space-y-2 text-gray-300">
              <p>地址：北京市朝阳区建国路88号</p>
              <p>电话：+86 10 8888 8888</p>
              <p>邮箱：info@cxgroup.com</p>
            </div>
          </div>
          
          <div>
            <h5 class="text-white mb-4">订阅我们</h5>
            <p class="text-gray-300 mb-4">订阅我们的新闻通讯，获取最新动态</p>
            <form class="flex">
              <input type="email" placeholder="您的邮箱" class="px-4 py-2 w-full rounded-l-md focus:outline-none" />
              <button type="submit" class="bg-primary hover:bg-primary-dark px-4 py-2 rounded-r-md">
                订阅
              </button>
            </form>
          </div>
        </div>
        
        <div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-300">
          <p>&copy; {{ new Date().getFullYear() }} {{ appStore.companyName }}. 保留所有权利。</p>
        </div>
      </div>
    </footer>
  </div>
</template>

<script setup lang="ts">
import { useAppStore } from '@/stores';

const appStore = useAppStore();
</script>